package server.layer;

/**
 * Created by IntelliJ IDEA.
 * User: Awake
 * Date: 24.03.12
 * Time: 17:38
 * To change this template use File | Settings | File Templates.
 */
public enum ServiceProtocol {
    CONNECT(".conn"), UPDATE_LIST(".update_list"), MODIFY_PERSON(".modify_person"), GET_DESCRIPTION(".get_description"),
    GET_IMAGE(".get_image"), DELETE_PERSON(".delete_person"), CLOSE_CONNECTION(".bye"),
    SEND_DESCRIPTION(".send_description"), SEND_IMAGE(".send_image"), ADD_PERSON(".add_person"), REMOVE_PLAYER(".remove");

    private ServiceProtocol(String abbr) {
        this.abbr = abbr;
    }

    public String getAbbr() {
        return abbr;
    }

    static public ServiceProtocol getCommand(String str) {
        for (ServiceProtocol sc : ServiceProtocol.values()) {
            if (sc.getAbbr().equals(str)) {
                return sc;
            }
        }
        throw new RuntimeException("unknown type");
    }

    private String abbr;
}
